package com.imm.da.main.weather.view

import android.content.Intent
import android.util.Log
import com.imm.da.R
import com.imm.da.base.vb.BaseVBActivity
import com.imm.da.databinding.ActivityWeatherBinding
import com.imm.da.main.city.view.CityListActivity
import com.imm.da.main.weather.model.WeatherViewModel
import com.imm.da.utils.ImgLoader

/**
 * <p>------------------------------------------------------
 * <p> Copyright (C) 2021 zhangmz, All rights reserved.
 * <p> If there is technical discussion, you can contact zhangmz90@foxmail.com
 * <p>------------------------------------------------------
 * <p> des
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2021/12/4
 */
class WeatherActivity : BaseVBActivity<WeatherViewModel>(R.layout.activity_weather) {

    private val binding by inflate<ActivityWeatherBinding>()

    override fun initActivity() {
        intent?.extras?.let { b ->
            val address = b.getString("address")
            val province = b.getString("province")
            val city = b.getString("city")
            val country = b.getString("country")
            Log.v("aaaaa", "country:$country; province:$province; city:$city; address:$address")

            viewModel.queryImage(city, success = {
                 ImgLoader.load(binding.bg, it.img)
            }, failure = {

            })
        }

        binding.fab.setOnClickListener { _ ->
            startActivity(Intent(this, CityListActivity::class.java))
        }
    }

}